<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #col {
            width: 500px;
            height: 500px;
            margin: 0 auto;
            border: 1px solid skyblue;
            background-color: #000001;
        }
    </style>
</head>

<body>
    <button id="btn">变颜色</button>
    <div id="col"></div>
    <script>
        var col = document.getElementById("col")
        // var btn = doucment.getElementById("btn")
        btn.onclick = function () {
            var str = "#"
            var color = parseInt(Math.random() * 16777216)
            col.style.backgroundColor = str + color
        }
    </script>
</body>

</html>